import {RoleEnum} from "../common/RoleEnum.js";

const currentUser = JSON.parse(sessionStorage.getItem("userInfo"));
// 是否有管理员权限
export const hasAdmin = () => {
   if (!currentUser) {
      return null;
   }
   return (currentUser.roleId === RoleEnum.ADMIN) || (currentUser.roles?.includes(RoleEnum.ADMIN))
};
// 是否有店长权限
export const hasManager = () => {
   if (!currentUser) {
      return null;
   }
   return (currentUser.roleId === RoleEnum.STORE_MANAGER) || (currentUser.roles?.includes(RoleEnum.STORE_MANAGER))
};

export const userId = () => {
   if (!currentUser) {
      return null;
   }
   return currentUser.userId;
};

export const user = () => {
   if (!currentUser) {
      return null;
   }
   return currentUser;
};

export const  hasRole = () => {

};
